Skip to content

Parametric google-test for mapping validation#13281

Merged
acolombier merged 22 commits into
mixxxdj:2.6from
JoergAtGithub:parametricGTestForMappings
Feb 23, 2026
Merged

Parametric google-test for mapping validation#13281
acolombier merged 22 commits into
mixxxdj:2.6from
JoergAtGithub:parametricGTestForMappings

Conversation

@JoergAtGithub
Copy link
Copy Markdown
Member

@JoergAtGithub JoergAtGithub commented May 25, 2024

For debugging #11625 (comment) I modified the googletest setup for mapping validation to use a parametrized list of mappings.
While the results look nice in my IDE, where I can easily debug a single mapping validation test now:
grafik

I was disappointed to see that CTest combines all the single GTest instances:

        Start 121: */LegacyControllerMappingValidationTest.ValidateMappingXML/*
121/840 Test #121: */LegacyControllerMappingValidationTest.ValidateMappingXML/* ...............................   Passed    0.37 sec
        Start 122: */LegacyControllerMappingValidationTest.LoadMapping/*
122/840 Test #122: */LegacyControllerMappingValidationTest.LoadMapping/* ......................................***Failed    5.44 sec

I could solve that by using gtest_discover_tests in the CMakelist.txt, now the CTest output looks like this:

          Start 1039: MidiMappingsValid/LegacyControllerMappingValidationTest.LoadMapping/Pioneer_CDJ_350_CH2#GetParam()=<MappingInfo>
1039/1107 Test #1039: MidiMappingsValid/LegacyControllerMappingValidationTest.LoadMapping/Pioneer_CDJ_350_CH2#GetParam()=<MappingInfo> .................................   Passed    0.45 sec
          Start 1040: MidiMappingsValid/LegacyControllerMappingValidationTest.LoadMapping/Pioneer_CDJ_850#GetParam()=<MappingInfo>
1040/1107 Test #1040: MidiMappingsValid/LegacyControllerMappingValidationTest.LoadMapping/Pioneer_CDJ_850#GetParam()=<MappingInfo> .....................................   Passed    0.45 sec
          Start 1041: MidiMappingsValid/LegacyControllerMappingValidationTest.LoadMapping/Pioneer_DDJ_200#GetParam()=<MappingInfo>
1041/1107 Test #1041: MidiMappingsValid/LegacyControllerMappingValidationTest.LoadMapping/Pioneer_DDJ_200#GetParam()=<MappingInfo> .....................................   Passed    0.53 sec
          Start 1042: MidiMappingsValid/LegacyControllerMappingValidationTest.LoadMapping/Pioneer_DDJ_400#GetParam()=<MappingInfo>
1042/1107 Test #1042: MidiMappingsValid/LegacyControllerMappingValidationTest.LoadMapping/Pioneer_DDJ_400#GetParam()=<MappingInfo> .....................................   Passed    0.45 sec
          Start 1043: MidiMappingsValid/LegacyControllerMappingValidationTest.LoadMapping/Pioneer_DDJ_FLX4#GetParam()=<MappingInfo>
1043/1107 Test #1043: MidiMappingsValid/LegacyControllerMappingValidationTest.LoadMapping/Pioneer_DDJ_FLX4#GetParam()=<MappingInfo> ....................................   Passed    0.47 sec

@JoergAtGithub JoergAtGithub force-pushed the parametricGTestForMappings branch from 7931539 to 2dc1f20 Compare May 25, 2024 13:49
@JoergAtGithub JoergAtGithub force-pushed the parametricGTestForMappings branch 3 times, most recently from 5e3e7cf to 58f0867 Compare May 26, 2024 17:16
@JoergAtGithub JoergAtGithub force-pushed the parametricGTestForMappings branch from fb7709b to c85d371 Compare May 26, 2024 19:22
@github-actions
Copy link
Copy Markdown

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions Bot added the stale Stale issues that haven't been updated for a long time. label Sep 24, 2024
Comment thread src/test/controller_mapping_validation_test.h Outdated
Comment thread src/test/controller_mapping_validation_test.cpp Outdated
Comment thread src/test/controller_mapping_validation_test.cpp Outdated
@github-actions github-actions Bot removed the stale Stale issues that haven't been updated for a long time. label Sep 25, 2024
@github-actions
Copy link
Copy Markdown

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions Bot added the stale Stale issues that haven't been updated for a long time. label Jan 23, 2025
@github-actions github-actions Bot removed the stale Stale issues that haven't been updated for a long time. label Sep 7, 2025
@acolombier
Copy link
Copy Markdown
Member

acolombier commented Nov 22, 2025

I think we should get this improvement in! I have taken some time to rebase this branch against 2.6 and add some minor improvement, related to @Swiftb0y suggestions

9f99d0158f

Let me know if you want me to submit it in a PR directly.

@JoergAtGithub
Copy link
Copy Markdown
Member Author

JoergAtGithub commented Nov 22, 2025

The problem is that this PR slows down the test significiantly, because creating the list of mappings takes a lot of time. A hardcoded list shouldn't have this issue.
Otherwise thi PR works.

@Swiftb0y
Copy link
Copy Markdown
Member

Swiftb0y commented Nov 22, 2025

what magnitude of slowdown are we talking about here? seconds?

@JoergAtGithub
Copy link
Copy Markdown
Member Author

The whole testsuite needs about 2x time as before, because the list of mappings is calculate before every test (not only the test that depend on this parameter)

@Swiftb0y
Copy link
Copy Markdown
Member

oh yeah, then that is a significant problem.

@acolombier
Copy link
Copy Markdown
Member

I have pushed a version with the mapping list computed directly in CMake. Only did MIDI as example, but keen to hear if we would want to go ahead with it. There is undoubtedly an overhead with running multiple tests, perhaps we could make it optional, so only the coverage job would run the test in parametrised mode and the slowdown wouldn't impact the build job?

@JoergAtGithub
Copy link
Copy Markdown
Member Author

GTest must always work standalone without CTest, as GTest is what is used in IDEs. One of the challenges to achieve this ist to find the ./res/controller directory in all environments.

@acolombier
Copy link
Copy Markdown
Member

Yes, this is what my solution does. It only finds the mapping at compile time to build the parameter list. Once built, mixxx-test can be used independently to CTest, and should work fine in the IDE as it will find the res/controller directory in the same way it predictably find src

@JoergAtGithub JoergAtGithub changed the base branch from main to 2.6 February 7, 2026 20:23
Use CMake to collect mapping files at configure time and pass them compile definition.
…rollers/midi-components-0.0.js:140:\nTypeError: Cannot call method 'trigger' of undefined\n\nBacktrace: @file:///home/runner/work/mixxx/mixxx/res/controllers/midi-components-0.0.js:140\ntrigger@file:///home/runner/work/mixxx/mixxx/res/controllers/midi-components-0.0.js:139\nComponent@file:///home/runner/work/mixxx/mixxx/res/controllers/midi-components-0.0.js:53\nButton@file:///home/runner/work/mixxx/mixxx/res/controllers/midi-components-0.0.js:164\n%entry@file:///home/runner/work/mixxx/mixxx/res/controllers/Hercules-P32-scripts.js:109
@JoergAtGithub JoergAtGithub marked this pull request as ready for review February 8, 2026 23:28
@JoergAtGithub
Copy link
Copy Markdown
Member Author

Finally ready, thanks to the suggestion by @acolombier above!

Copy link
Copy Markdown
Member

@acolombier acolombier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks for pushing this to the end! I haven't tested it yet

if (this.connections[0] !== undefined) {
this.connections.forEach(function(conn) {
conn.disconnect();
if (conn !== undefined) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an expected usecase? It does makes sense in the case of testing due to missing CO, but I assume that connections should only contain valid connections, else it would indicate a problem.
Should we add a console.warn to flag potentially failed connection?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detailed warnings are already implemented in engine.makeConnection:

if (coScript == nullptr) {
// The test setups do not run all of Mixxx, so ControlObjects not
// existing during tests is okay.
if (!m_pScriptEngineLegacy->isTesting()) {
m_pScriptEngineLegacy->logOrThrowError(
QStringLiteral("script tried to connect to ControlObject "
"(%1, %2) which is non-existent.")
.arg(group, name));
}
return QJSValue();
}
if (!callback.isCallable()) {
m_pScriptEngineLegacy->logOrThrowError(QStringLiteral(
"Tried to connect (%1, %2) to an invalid callback. Make sure "

But after the warning engine.makeConnection returns undefined and the script continues.

Comment thread src/test/controller_mapping_validation_test.cpp Outdated
Comment thread src/test/controller_mapping_validation_test.cpp Outdated
Comment thread src/test/controller_mapping_validation_test.h Outdated
Comment thread CMakeLists.txt
PUBLIC CONTROLLER_HID_MAPPINGS="${CONTROLLER_HID_MAPPINGS}"
PUBLIC CONTROLLER_MIDI_MAPPINGS="${CONTROLLER_MIDI_MAPPINGS}"
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DO we need to make the above conditional to HID, and BULK?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the simplicity of the code is of more value than skiping 1 or 2 regular expressions during CMake configuration.

Copy link
Copy Markdown
Member

@acolombier acolombier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! This seems to slow down the test run by about 30 seconds (for Ubuntu). That being said, the added value is worth the delay IMO.

Giving some time to let other member a chance to review this as well.

@acolombier acolombier mentioned this pull request Feb 15, 2026
2 tasks
@JoergAtGithub
Copy link
Copy Markdown
Member Author

Merge?

@acolombier acolombier merged commit e45fc6f into mixxxdj:2.6 Feb 23, 2026
14 checks passed
@JoergAtGithub JoergAtGithub deleted the parametricGTestForMappings branch February 23, 2026 21:20
@github-project-automation github-project-automation Bot moved this to In progress in Releases Feb 25, 2026
@github-project-automation github-project-automation Bot moved this from In progress to Done in Releases Feb 25, 2026
@acolombier acolombier added this to the 2.6.0 milestone Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants